package anji.plus.system.mark.dto;

import lombok.Data;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 任务表
 * </p>
 *
 * @author luwei
 * @since 2023-11-08
 */
@Data
public class userFlagInfo {

    private static final long serialVersionUID = 1L;


    /**
     * 用户名
     */
    private Long id;

    /**
     * 用户名
     */
    private String name;

    /**
     * FLAG名称
     */
    private String flagName;

    /**
     * FLAG详情备注
     */
    private String flagInfo;

    /**
     * 完成时间
     */
    private String flagCompleteTime;

    /**
     * 进度
     */
    private String flagProgress;

    public String getFlagProgress() {
        if (this.flagProgress == null) {
            return "0.00";
        }
        return flagProgress;
    }

    /**
     * 点赞数
     */
    private String flagMark;

    /**
     * 完成情况
     */
    private String flagCompleteInfo;

    public String getFlagCompleteInfo() {
        if (this.flagCompleteInfo == null) {
            return "";
        }
        return flagCompleteInfo;
    }
    /**
     * 完成情况
     */
    private String createTime;

    public String getCreateTime() {
        if (this.createTime == null) {
            return "";
        }
        String result = createTime.substring(0, 19);
        return result;
    }


    /**
     * 修改时间
     */
    private String updtaeTime;

    public String getUpdtaeTime() {
        if (this.updtaeTime == null) {
            return "";
        }
        String result = updtaeTime.substring(0, 19);
        return result;
    }

    /**
     * 计划进度
     */
    private long planProgress;

    public double getPlanProgress() {
        Date currentDate = new Date();

        Date createDate = null;
        try {
            createDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(this.createTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        Date completeDate = null;
        try {
            completeDate = new SimpleDateFormat("yyyy-MM-dd").parse(this.flagCompleteTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        if(currentDate.compareTo(completeDate) <0 ){

        long milliSeconds01 = completeDate.getTime() - createDate.getTime();
        long days01= milliSeconds01/(1000*60*60*24) +1;

        long milliSeconds02 = currentDate.getTime() - createDate.getTime();
        long days02= milliSeconds02/(1000*60*60*24) +1;

        double result = ((double)days02*100/(double)days01);
        return result;

        }else
        {
            return 100;
        }

    }

}
